<template>
	<div>
  <div style="margin-top:20px;background-color:#ffffff00;" :elevation="0">
    <v-list-item>
      <v-list-item-avatar><img :src="head_img" alt="avatar"></v-list-item-avatar>
      <v-list-item-content>
        <v-list-item-title class="title">{{ name }}</v-list-item-title>
        <v-list-item-subtitle>{{ "+"+itac +""+ phone }}</v-list-item-subtitle>
      </v-list-item-content>
    </v-list-item>

    <v-card-actions>
      <v-btn text color="">
        余额：{{ cash }}
      </v-btn>
      <v-btn text color="">
        积分：{{ point }}
      </v-btn>
      <div class="flex-grow-1"></div>
      <v-btn icon>
        <v-icon>mdi-share-variant</v-icon>
      </v-btn>
    </v-card-actions>
  </div>
    <v-list shaped style="margin-top:20px;background-color:#ffffff00;">
      <v-divider></v-divider>
				<div >
        <v-list-item @click="cto(member.to)">
          <v-list-item-icon >
            <v-icon v-text="member.icon"></v-icon>
          </v-list-item-icon>
          <v-list-item-content>
            <v-list-item-title class="font-size" v-text="member.text"></v-list-item-title>
          </v-list-item-content>
        </v-list-item>
				</div>
      <v-list-item-group v-model="item" color="primary">
				<div v-for="(item, i) in items" :key="i">
        <v-list-item @click="cto(item.to)">
          <v-list-item-icon >
            <v-icon v-text="item.icon"></v-icon>
          </v-list-item-icon>
          <v-list-item-content>
            <v-list-item-title class="font-size" v-text="item.text"></v-list-item-title>
          </v-list-item-content>
        </v-list-item>
				</div>
      </v-list-item-group>
    </v-list>

	</div>
</template>


<script>
import { userinfo, URLP } from './../../api/api'
export default {
  data:() => ({
		name:'',
		phone:'',
    ismember:false,
    itac:'',
    grade:'',
    item: '',
    cash:'',
    point:'',
    renew_at:'',
    exp_at:'',
    card_no:'',
    head_img:'',
    member:{
      text: '付费会员',
      to : '/pay/member',
      icon: 'redeem'
    },
		items: [
        { text: '订单管理', icon: 'find_in_page', to: '/order/management' },
        { text: '人工核保', icon: 'feedback', to: '/underwriter/create/order' },
        { text: '咨询港医', icon: 'feedback', to: '/workorder/create/order' },
        { text: '我的消息', icon: 'info', to: '/message/list' },
      ],
  }),
  methods:{
    cto:function(path){
      this.$router.push(path)
    }
  },
  created: function(){
    window.co = this.$cookies
    this.$store.commit('setProgress',true)
    console.log(this.$cookies.get("authtoken"))
    userinfo(this.$cookies.get("authtoken"))
    .then((resp)=>{
      var res = resp.data
      console.log(res)

      if(res.code==1){
        this.name = res.data.user.name
        this.itac = res.data.user.itac
        this.phone = res.data.user.phone
        this.head_img = res.data.user.head_img
        this.grade = res.data.member.grade
        this.cash = res.data.member.cash
        this.point = res.data.member.point
        this.grade = res.data.member.grade
        this.renew_at = res.data.member.renew_at
        this.exp_at = res.data.member.exp_at
        this.card_no = res.data.member.card_no
        if (res.data.member.grade > 0) {
          this.ismember = true
          this.member.text = "会员特权"
          this.member.to = "/user/member"
        }
      }else{
        if(res.result.errcode=2001){
          console.log("绑定微信")
          // this.$router.push({path:'/login'})
        }
        console.log("失败")
      }
       this.$store.commit('setProgress',false)
    })
    .catch((res)=>{
       this.$store.commit('setProgress',false)
      // this.$store.commit('setProgress',false)
      //this.$router.push({path:'/login'})
      
    })
  },
}
</script>

<style>
.font-size {
	font-size:0.5rem;
}
  a {
    text-decoration: none;
  }

  .router-link-active {
    text-decoration: none;
  }
</style>